package com.hexiang.web;

import com.hexiang.entity.BookReqDto;
import com.hexiang.entity.ResultResponse;
import com.hexiang.service.BookConsumerService;
import com.hexiang.web.vo.BookRequestVO;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author h01463
 * @version 1.0
 * @date 2024/7/26 15:45
 */
@RestController
public class BookConsumerController {

    @Resource
    private BookConsumerService bookConsumerService;

    /**
     * @param newBook
     */
    @PostMapping("/createBook")
    public ResultResponse createBook(@RequestBody BookRequestVO newBook) {
        BookReqDto bookReqDto = new BookReqDto();
        BeanUtils.copyProperties(newBook, bookReqDto);
        return bookConsumerService.createBook(bookReqDto);
    }
}
